package day24;

import java.io.*;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;

/**
 * @author ZJX
 * @version 1.0
 * @descption
 * @since 2025/11/2 18:34
 */
public class Day19 {
//    public static void main(String[] args) throws IOException {
//        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//        PrintWriter out = new PrintWriter(System.out);
//        in.nextToken();
//        int n = (int) in.nval;
//        in.nextToken();
//        long x = (long) in.nval; // 初始战斗力
//        while (n-- > 0) {
//            in.nextToken();
//            int t = (int) in.nval; // 怪物战斗力
//            if (x >= t) {
//                x += t;
//            } else {
//                x += gcd(x, t);
//            }
//        }
//        out.println(x);
//        out.close();
//    }

    public static long gcd(long a, int b) {
        while (b != 0) {
            int temp = b;
            b = (int) (a % b);
            a = temp;
        }
        return a;
    }

    /**
     * @param grid int整型二维数组
     * @return int整型
     */
    public int maxValue(int[][] grid) {
        int m = grid.length;
        int n = grid[0].length;
        int[][] dp = new int[m + 1][n + 1];
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]) + grid[i - 1][j - 1];
            }
        }
        return dp[m][n];
    }

    public static void main(String[] args) throws IOException {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(System.out);
        in.nextToken();
        int t = (int) in.nval;
        while (t-- > 0) {
            in.nextToken();
            int n = (int) in.nval; // 字符串长度
            String[] s = new String[n];
            for (int i = 0; i < n; i++) {
                in.nextToken();
                s[i] = in.sval;
            }
            int left = 0, right = s.length - 1;
            boolean isForm = true;
            while (right > left) {
                if (!hasCommonChar(s[left], s[right])) {
                    isForm = false;
                    break;
                }
                left++;
                right--;
            }
            out.println(isForm ? "Yes" : "No");
            out.close();
        }
        out.close();
    }

    private static boolean hasCommonChar(String s1, String s2) {
        HashSet<Character> set = new HashSet<>();
        for (char c : s1.toCharArray()) {
            set.add(c);
        }
        for (int i = 0; i < s2.length(); i++) {
            if (set.contains(s2.charAt(i))) {
                return true;
            }
        }
        return false;
    }


    public void sortColors(int[] nums) {
        // 荷兰国旗问题
        int low = 0, mid = 0, high = nums.length - 1;
        while (mid <= high) {
            if (nums[mid] == 0) {
                swap(nums, low++, mid++);
            } else if (nums[mid] == 1) {
                mid++;
            } else {
                swap(nums, mid++, high--);
            }
        }
    }

    private void swap(int[] nums, int i, int j) {
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }

    /**
     * 腐烂的橘子
     *
     * @param grid 网格
     * @return 腐烂的最小时间
     */
    public int orangesRotting(int[][] grid) {
        if (grid == null || grid.length == 0) {
            return 0;
        }
        int row = grid.length;
        int col = grid[0].length;
        int freshOrange = 0;
        Queue<int[]> queue = new LinkedList<>();
//        1. 初始化
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < col; j++) {
                if (grid[i][j] == 1) {
                    freshOrange++;
                } else if (grid[i][j] == 2) {
                    queue.offer(new int[]{i, j});
                }
            }
        }
        if (freshOrange == 0) {
            return 0;
        }
        int time = 0;
        int[][] dirs = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
        while (!queue.isEmpty()) {
            int size = queue.size();
            for (int i = 0; i < size; i++) {
                int[] poll = queue.poll();
                int x = poll[0];
                int y = poll[1];
                for (int[] dir : dirs) {
                    int nx = x + dir[0];
                    int ny = y + dir[1];
                    if (nx >= 0 && nx < row && ny >= 0 && ny < col && grid[nx][ny] == 1) {
                        grid[nx][ny] = 2;
                        queue.offer(new int[]{nx, ny});
                        freshOrange--;
                    }
                }
            }
            if (!queue.isEmpty()) {
                time++;
            }
        }
        return freshOrange == 0 ? time : -1;
    }

    public boolean searchMatrix(int[][] matrix, int target) {
        if (matrix == null || matrix.length == 0 || matrix[0].length == 0) {
            return false;
        }
        int rows = matrix.length;
        int cols = matrix[0].length;
        int row = 0;
        int col = cols - 1;
        while (rows > row && col >= 0) {
            int cur = matrix[row][col];
            if (cur == target) {
                return true;
            } else if (cur > target) {
                col--;
            } else {
                row++;
            }
        }
        return false;
    }

    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int i = m - 1;
        int j = n - 1;
        int index = m + n - 1;
        while (i >= 0 && j >= 0) {
            if (nums1[i] > nums2[j]) {
                nums1[index--] = nums1[i--];
            } else {
                nums1[index--] = nums2[j--];
            }
        }
        while (j >= 0) {
            nums1[index--] = nums2[j--];
        }
    }
}

